<?php
//date格格式化一个本地时间/日期
//格式字符串：（1）普通字符原样显示（2）特殊字符，的特定的含义
echo date("北京时间:Y年m月d日 H:i:s.v e\n");

$d=new DateTime();
$d=new DateTime("2000-10");
$d=new DateTime("2000-10-5");
$d=new DateTime("2000-10 12:34:56");
$d=new DateTime("2000-10 12:34");
$d=new DateTime("12:34");
$d=new DateTime("20001005 123456");
$d=new DateTime("2000/10/1 12:34:56");
print_r($d);

echo $d->format("Y-m-d H:i:s.v e\n");
echo $d->format("年:Y\n");
$a=["name"=>"zs","age"=>18];

$d=new DateTime("1970-1-1 8:0",new DateTimeZone("Asia/shanghai"));
echo "UNIX时间戳:",$d->getOffset(),"\n";

echo (new DateTime("@1761723189"))->format("Y-m-d H:i:s.v e\n");

$d=new DateTime();
echo $d->format("Y-m-d H:i:s.v e\n");
$d->setTimezone(new DateTimeZone("UTC"));
echo $d->format("Y-m-d H:i:s.v e\n");


$d=new DateTimeImmutable("2025-10-29 12:34:56");
echo $d->format("北京时间:Y-m-d H:i:s.v e\n");
echo $d->modify("+1 day")->format("Y-m-d H:i:s.v e\n");
echo $d->modify("-2 day")->format("Y-m-d H:i:s.v e\n");
echo $d->setDate(2000,10,1)->format("Y-m-d H:i:s.v e\n");
echo $d->modify("2000-10")->format("Y-m-d H:i:s.v e\n");
echo $d->setTime(23,45,)->format("Y-m-d H:i:s.v e\n");


echo $d->modify("monday this week")->format("Y-m-d H:i:s.v e\n");
echo $d->modify("monday last week")->format("Y-m-d H:i:s.v e\n");
echo $d->modify("monday next week")->format("Y-m-d H:i:s.v e\n");

$currentweek=9;
echo (new DateTime())
    ->modify("monday-$currentweek weeks+8 hours")
    ->format("Y-m-d H:i:s.v e\n");





